const express = require('express');
const router = express.Router();
const pddService = require('../services/pdd.service');

// 解析拼多多口令
router.post('/parse-command', async (req, res) => {
  try {
    const { command } = req.body;
    if (!command) {
      return res.status(400).json({
        code:500,
        message: '口令不能为空'
      });
    }

    const goodsInfo = await pddService.parseCommand(command);
    res.json({
      success: true,
      data: goodsInfo
    });
  } catch (error) {
    console.error('解析拼多多口令失败:', error);
    res.status(500).json({
      code:500,
      message: error.message || '解析口令失败'
    });
  }
});

module.exports = router; 